/* Generates predicted hazards by sampling from the betas of the Weibull coup attempts model */

set more off

set mem 100m

use "c:\Data Sets\Africa\africa_1.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_1.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_1.dta", replace

use "c:\Data Sets\Africa\africa_2.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_2.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_2.dta", replace

use "c:\Data Sets\Africa\africa_3.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_3.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_3.dta", replace

use "c:\Data Sets\Africa\africa_4.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_4.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_4.dta", replace

use "c:\Data Sets\Africa\africa_5.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_5.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_5.dta", replace

use "c:\Data Sets\Africa\africa_6.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_6.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_6.dta", replace

use "c:\Data Sets\Africa\africa_7.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_7.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_7.dta", replace

use "c:\Data Sets\Africa\africa_8.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_8.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_8.dta", replace

use "c:\Data Sets\Africa\africa_9.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_9.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_9.dta", replace

use "c:\Data Sets\Africa\africa_10.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
bsample 
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu WoverS Wgrow if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

use "c:\Data Sets\Africa\africa_10.dta", clear
drop pfall
predict pfall, hazard
replace pfall=0 if nogovrn2==1 | govdurneg==1
replace IMFpfall = imfstatu*pfall
replace rfall=pmpty_s*pfall
replace rfall=0 if nogovrn2==1 | govdurneg==1
replace IMFrfall=rfall*imfstatu

save "c:\Data Sets\Africa\africa_10.dta", replace

